Libraries
tidyverse: data transformations and beautiful plots (Wickham et al. 2019).
hrbrthemes: this contains the ipsum theme, a very simple and elegant theme (Rudis 2020).
rmarkdown: all the structure of the report relies on this library (Allaire et al. 2020).
bookdown: allows the bibliography on the YAML header of this Rmarkdown doc (Xie 2016, 2020a).
epuRate: the elegant theme of the report (Holtz 2020).
knitr: all parts integration to render the output reporducible report (Xie 2014, 2015, 2020b).
citr: addin for easyly find citations in the .bib file and insert in the correct format (Aust 2019).
icon inserting many different icons in markdown (O’Hara-Wild 2020).
ggridges plotting the density in single rows like ridges and moreover (Wilke 2020).
ggrepel avoid labels overlapping (Slowikowski 2020).
This is my first Tidy Tuesday contribution and will be playing around a little bit with the coffee rating data .
As a coffee lover I felt that exploring a dataset about coffee was mandatory. The first question that came to me mind was: what is the best coffee and eventually, as looking a little bit deeper into dataset, which country has the best coffees.
I decided then to compare coffee ratings across countries and the associated density of cups rated. Among the main findings it shows that one Ethiopian coffee came to be the best ranked and also that this country’s coffees are the best ranked while Haitian coffees show one of the widest range of ratings. Colombian coffee display a moderately good ratings and a very narrow range.
coffee <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-07-07/coffee_ratings.csv')
head(coffee)coffee %>%
drop_na(any_of("country_of_origin")) %>%
filter(aroma != 0 & !country_of_origin %in% c("Zambia", "Rwanda", "Papua New Guinea", "Japan", "Mauritius", "Cote d?Ivoire")) %>%
ggplot(aes(x = total_cup_points, y = country_of_origin, fill = stat(x), label = owner)) +
geom_density_ridges_gradient(show.legend = T, alpha = .5, point_alpha = 0.5, jittered_points = TRUE) +
theme_ipsum() +
scale_fill_viridis_c(alpha = 0.7) +
ylab("") +
xlab("Total cup points") +
labs(title = "Comparison of coffee's ratings across countries and its distribution",
subtitle = "Ethiopian coffees seem to be the best. Latinoamerican countries were more abundant in the competition",
caption = "Data: TidyTuesday week 28. Visualization: @Gaspardelanoche",
fill = "Total cup points"
) +
theme(
plot.title = element_text(size = 20, face = "bold"),
plot.subtitle = element_text(size = 18),
axis.title.x = element_text(size = 18),
axis.title.y = element_text(size = 18),
axis.text.y = element_text(size = 18),
plot.caption = element_text(size = 16)
) +
geom_label_repel(
data = subset(coffee,total_cup_points > 88),
force = 10,
xlim = c(88,NA)
)Fig 1. Comparison of the different coffee ratings for the different cups across countries and its associate distribution coffee cups.
Allaire, JJ, Yihui Xie, Jonathan McPherson, Javier Luraschi, Kevin Ushey, Aron Atkins, Hadley Wickham, Joe Cheng, Winston Chang, and Richard Iannone. 2020. Rmarkdown: Dynamic Documents for R. https://CRAN.R-project.org/package=rmarkdown.
Aust, Frederik. 2019. Citr: RStudio Add-in to Insert Markdown Citations. https://CRAN.R-project.org/package=citr.
Holtz, Yan. 2020. EpuRate: A Clean Template for R Markdown Documents.
O’Hara-Wild, Mitchell. 2020. Icon: SVG Icons for R Documents and Apps. https://github.com/mitchelloharawild/icon.
Rudis, Bob. 2020. Hrbrthemes: Additional Themes, Theme Components and Utilities for ’Ggplot2’. https://CRAN.R-project.org/package=hrbrthemes.
Slowikowski, Kamil. 2020. Ggrepel: Automatically Position Non-Overlapping Text Labels with ’Ggplot2’. https://CRAN.R-project.org/package=ggrepel.
Wickham, Hadley, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D’Agostino McGowan, Romain Fran??ois, Garrett Grolemund, et al. 2019. “Welcome to the tidyverse.” Journal of Open Source Software 4 (43): 1686. https://doi.org/10.21105/joss.01686.
Wilke, Claus O. 2020. Ggridges: Ridgeline Plots in ’Ggplot2’. https://CRAN.R-project.org/package=ggridges.
Xie, Yihui. 2014. “Knitr: A Comprehensive Tool for Reproducible Research in R.” In Implementing Reproducible Computational Research, edited by Victoria Stodden, Friedrich Leisch, and Roger D. Peng. Chapman; Hall/CRC. http://www.crcpress.com/product/isbn/9781466561595.
———. 2015. Dynamic Documents with R and Knitr. 2nd ed. Boca Raton, Florida: Chapman; Hall/CRC. https://yihui.org/knitr/.
———. 2016. Bookdown: Authoring Books and Technical Documents with R Markdown. Boca Raton, Florida: Chapman; Hall/CRC. https://github.com/rstudio/bookdown.
———. 2020a. Bookdown: Authoring Books and Technical Documents with R Markdown. https://CRAN.R-project.org/package=bookdown.
———. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in R. https://CRAN.R-project.org/package=knitr.
A work by Camilo Garcia